 package GameLogic
{
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.ui.Mouse;
	import flash.ui.MouseCursor;
	public class ApiItem extends Sprite
	{
		public var ApiName:TextField;
		public var Remark:String;
		public var apiName:String;
		private var note:String;
		private var shape:Shape;
		private var w:int = 240;
		private var h:int = 21;
		private var border:Shape =  new Shape();
		public function ApiItem(_apiName:String,_note:String,_remark:String,_s:Boolean = false)
		{
			var clr:int = 0x3E3A3A;
			if (_s)
			   clr = 0x525151;
			apiName = _apiName;
			note = _note;
			ApiName = new TextField();
			ApiName.text = apiName;
			ApiName.width = w;
			ApiName.height = h;
			ApiName.textColor = 0xffffff;
			ApiName.selectable = false;
			Remark = _remark;
			shape =  new Shape();
			shape.graphics.beginFill(clr, 0.9);
			shape.graphics.drawRect(0, 0, w, h);
			addChild(shape);
			addChild(ApiName);
			border.graphics.lineStyle(1, 0xffffff);
			border.graphics.drawRect(0, 0, w-1, h);
			border.visible = false;
			addChild(border);
			
			addEventListener(MouseEvent.MOUSE_OVER, function(e:Event):void
			 {
			    Mouse.cursor = MouseCursor.BUTTON;
			    border.visible = true;
				border.alpha = 0.5;
				shape.alpha = 1;	
				AddToolip();
			});
			addEventListener(MouseEvent.MOUSE_OUT, function(e:Event):void
			{
				Mouse.cursor = MouseCursor.AUTO;
				Game.RemoveTooltip();
				shape.alpha = 0.9;
			    border.visible = false;
			});
			this.addEventListener(MouseEvent.CLICK, function(e:Event):void
			{
				Game.LuaEdit.PutChoiseApi(Remark, apiName);
				Game.LuaEdit.CurrentapiEdit = apiName;
			});
		}
		
		private function AddToolip():void
		{
			Game.AddTooltip(this, ApiName, note, 130, 0);
		}
	}
}